home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 10800 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. From: root@205.218.34.39 (where is my fish?)
  2. Subject: Re: C calling C++ function????
  3. Newsgroups: comp.lang.c++
  4. References: <4g07q4$doh@ornews.intel.com> <4g50u7$fcp@izar.brunel.ac.uk>
  5. Reply-To: wjl@sisna.com
  6. X-Newsreader: TIN [version 1.2 PL2]
  7. NNTP-Posting-Host: dialup1339.sisna.com
  8. Message-ID: <313fd401.0@news.sisna.com>
  9. Date: 8 Mar 96 06:30:25 GMT
  10. Path: 205.218.34.39!root
  11.  
  12. Francesco Fantauzzi (mapgfgf@brunel.ac.uk) wrote:
  13. : Chad_Bryant@ccm.fm.intel.com (Chad Bryant) wrote:
  14. : >I've got a c program and I want to use a c++ function that I have
  15. : >written. What do I need to do?
  16. : >please reply to Chad_Bryant@ccm.fm.intel.com
  17.  
  18. : Call it.
  19.  
  20. : Francesco G. Fantauzzi
  21.  
  22. Too bad it's not always that easy. Most C++ compilers to name mangling on the
  23. functions, so you can't just "call it." The way to get arround this is to
  24. declare the C++ function like this:
  25.  
  26. extern "C" {
  27.     int my_c++_function();
  28.     void my_ther_c++_function();
  29. }
  30.  
  31. and so forth. This stops the compiler from using name mangling, but watch out!
  32. You can't overload two "C" functions with the same name--as name mangling is
  33. the only way overloading can work. :)
  34.  
  35. --
  36. where is my fish?
  37. wjl@sisna.com
  38. wjl@blarg.net
  39. wjl@byu.edu
  40.